From: Jan Beulich Date: Mon, 22 Jul 2019 09:59:01 +0000 (+0200) Subject: AMD/IOMMU: free more memory when cleaning up after error X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~1876 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=6ae22e7aac8fb0d39318eb27eab439dd97521174;p=xen.git AMD/IOMMU: free more memory when cleaning up after error The interrupt remapping in-use bitmaps were leaked in all cases. The ring buffers and the mapping of the MMIO space were leaked for any IOMMU that hadn't been enabled yet. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Acked-by: Brian Woods --- diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c index 4e76b2620c..35d3a77a79 100644 --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -1070,13 +1070,12 @@ static void __init amd_iommu_init_cleanup(void) { list_del(&iommu->list); if ( iommu->enabled ) - { disable_iommu(iommu); - deallocate_ring_buffer(&iommu->cmd_buffer); - deallocate_ring_buffer(&iommu->event_log); - deallocate_ring_buffer(&iommu->ppr_log); - unmap_iommu_mmio_region(iommu); - } + + deallocate_ring_buffer(&iommu->cmd_buffer); + deallocate_ring_buffer(&iommu->event_log); + deallocate_ring_buffer(&iommu->ppr_log); + unmap_iommu_mmio_region(iommu); xfree(iommu); } diff --git a/xen/drivers/passthrough/amd/iommu_intr.c b/xen/drivers/passthrough/amd/iommu_intr.c index da3c3c1a44..925651ec2d 100644 --- a/xen/drivers/passthrough/amd/iommu_intr.c +++ b/xen/drivers/passthrough/amd/iommu_intr.c @@ -610,6 +610,8 @@ int __init amd_iommu_free_intremap_table( { void *tb = ivrs_mapping->intremap_table; + XFREE(ivrs_mapping->intremap_inuse); + if ( tb ) { __free_amd_iommu_tables(tb, INTREMAP_TABLE_ORDER);